package com.itheima.service.impl;

import com.itheima.dao.AccountDao;
import com.itheima.domain.Account;
import com.itheima.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;

    @Override
    public void transfer(Integer outId, Integer inId, Double money) {
        //outId减100元
        accountDao.transfer(outId,-money);
        //int i = 1/0; //手动写异常
        //inId加100元
        accountDao.transfer(inId,money);
    }

    @Override
    public List<Account> findAll() {
        //查询表中的全部信息
       return accountDao.findAll();
    }


}
